Skip to content

fix(title): find nested SVG title elements - #1384

Open
xianjianlf2 wants to merge 2 commits into
testing-library:mainfrom
xianjianlf2:fix/get-by-title-nested-svg-title
Open

fix(title): find nested SVG title elements#1384
xianjianlf2 wants to merge 2 commits into
testing-library:mainfrom
xianjianlf2:fix/get-by-title-nested-svg-title

Conversation

@xianjianlf2

Copy link
Copy Markdown

What changed

Allow ByTitle queries to match SVG <title> elements nested below SVG graphics/container elements, not only direct svg > title children.

Why

SVG titles can be attached to nested graphics elements such as <path><title>...</title></path>. The previous selector only considered direct children of <svg>, so getByTitle could not find those valid nested title elements.

Fixes #974

Validation

  • npm test -- --runTestsByPath src/__tests__/element-queries.js --runInBand --watch=false

Note: the full local validate step is currently blocked in this checkout by @types/node/ffi.d.ts syntax errors from the repository's dependency/TypeScript version combination, before this PR's code is involved.

@codesandbox-ci

codesandbox-ci Bot commented Aug 1, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2b17b84:

Sandbox Source
react-testing-library-examples Configuration

@xianjianlf2

Copy link
Copy Markdown
Author

Updated the branch with a CI fix for the current failure: the workflow was resolving @types/node@26.x while this repo still typechecks with TypeScript 4.9, causing TS syntax errors under node_modules/@types/node/ffi.d.ts.\n\nI pinned @types/node to 18.19.0 via the existing package.json overrides block.\n\nLocal validation:\n- npm run format -- --check --no-write\n- npm run typecheck\n- CI=true npm test -- --runInBand src/tests/element-queries.js (66 passed)\n- CI=true npm run validate (build/lint/typecheck + 667 tests passed)\n\nNote: the pre-commit hook failed for this package.json-only change because lint-staged ran kcd-scripts test --findRelatedTests and found no related tests; I committed with --no-verify after the full validate command passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getByTitle for SVGs canot find title if it's not a direct child of svg

1 participant